/*
Copyright 2021 Vladimir Smagin.
*/

package v1

import (
	v1 "k8s.io/api/core/v1"
	"k8s.io/apimachinery/pkg/api/resource"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// SingleRedisSpec defines the desired state of SingleRedis
type SingleRedisSpec struct {
	Image      string         `json:"image,omitempty"`      // default redis:latest
	PullPolicy *v1.PullPolicy `json:"pullPolicy,omitempty"` // default "if not exists"

	// Persistence options
	// Set volume size if you want persistence or EmptyDir will be used
	PersistentVolumeSize  *resource.Quantity `json:"persistentVolumeSize,omitempty"`  // default empty
	PersistentVolumeClass string             `json:"persistentVolumeClass,omitempty"` // default empty
	// You can mount persistent volume to another place, or use automatically generated /data
	PersistentVolumePath string `json:"persistentVolumePath,omitempty"` // default empty
	// This option purges PVC afrer CR was deleted. Mostly used for development deployments.
	PersistentVolumePurge bool `json:"persistentVolumePurge,omitempty"` // default false
	// You can use custom configmap, or use automatically generated
	Configmap string `json:"configmap,omitempty"` // use custom configmap as redis.conf

	RedisPodRequests  v1.ResourceList    `json:"podRequests,omitempty"`
	RedisPodLimits    v1.ResourceList    `json:"podLimits,omitempty"`
	RedisAffinity     *v1.Affinity       `json:"affinity,omitempty"`
	RedisNodeSelector *map[string]string `json:"nodeSelector,omitempty"`
	RedisTolerations  *[]v1.Toleration   `json:"tolerations,omitempty"`
}

// SingleRedisStatus defines the observed state of SingleRedis
type SingleRedisStatus struct {
	// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
	// Important: Run "make" to regenerate code after modifying this file
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

// SingleRedis is the Schema for the singleredis API
type SingleRedis struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   SingleRedisSpec   `json:"spec,omitempty"`
	Status SingleRedisStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// SingleRedisList contains a list of SingleRedis
type SingleRedisList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []SingleRedis `json:"items"`
}

func init() {
	SchemeBuilder.Register(&SingleRedis{}, &SingleRedisList{})
}
